# -*- coding: UTF-8 -*-

from xeres import *

from ui import font
from ui_helper import *

# Controls provide better Python behavior from xeres.

DEFAULT_TEXT = ""
DEFAULT_POS = Point(0,0)
DEFAULT_PLACEMENT = rect(0,0,1,1)

# Label control.
class Label( XLabel ):
	def __init__( self, parent=None, text=DEFAULT_TEXT, placement=DEFAULT_PLACEMENT ):
		super(Label,self).__init__( text, placement )
		if parent:
			parent.AddChild( self )

# Buttton.
class Button( XButton ):
	def __init__( self, parent=None, text=DEFAULT_TEXT, placement=DEFAULT_PLACEMENT, on_click=None ):
		super(Button,self).__init__( text, placement )
		if parent:
			parent.AddChild( self )
		if on_click:
			self.SetOnClick( on_click )

# Simple Button.
class SimpleButton( XSimpleButton ):
	def __init__( self, parent=None, text=DEFAULT_TEXT, image=None, pos=DEFAULT_POS, on_click=None ):
		super(SimpleButton,self).__init__( text, image, pos )
		if parent:
			parent.AddChild( self )
		if on_click:
			self.SetOnClick( on_click )
		# set tips
		self.tips = None
		self.SetOnHover( self.on_tips )

	# callback on tips show	
	def on_tips( self ):
		if self.tips:
			desktop.TrackTips( self , self.tips )

# Edit control.
class Edit( XEditCtrl ):
	def __init__( self, parent=None, placement=DEFAULT_PLACEMENT ):
		super(Edit,self).__init__( placement, font.font() )
		if parent:
			parent.AddChild( self )

# Click label.
class ClickLabel( XClickLabel ):
	def __init__( self, parent=None, text=DEFAULT_TEXT, placement=DEFAULT_PLACEMENT, on_click=None ):
		super(ClickLabel,self).__init__( text, placement )
		if parent:
			parent.AddChild( self )
		if on_click:
			self.SetOnClick( on_click )

# Image (no interactive control).
class Image( XImage ):
	def __init__( self, parent=None, image=None, placement=DEFAULT_PLACEMENT ):
		super(Image,self).__init__( image, placement )
		if parent:
			parent.AddChild( self )



